<%@page import="com.yyj.domain.Goods"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商城</title>
<link rel="stylesheet" href="css/home1.css" type="text/css" >
</head>
<body>
<!-- 判断用户是否登录 -->
<c:set var="user" scope="session" value="${user}"/>
<c:choose>
   <c:when test="${empty user}" >
<div class="user">
<div id="welcome">汪  欢迎来到天狗</div>

<div id="dl">
<li id="z-dl"><a  href="${pageContext.request.contextPath}/login.do">登录</a></li>
<li id="z-dl"><a  href="${pageContext.request.contextPath}/register.do">免费注册</a></li>
</div>
</div>
</c:when>
<c:otherwise>
<div class="user">
<div id="welcome">汪  来啦老弟 </div>
<form action="${pageContext.request.contextPath }/my.do" id="u-form">
<input type="text" value="${user.account }" id="account">
<input type="submit" value="你好${user.nickname }" id="t-user">
</form>
</div>
</c:otherwise>
</c:choose>


<div class="sousuo">
 <div>
 <img alt="" src="img/jd.jpg" id="logo">
 </div>
 <div class="f-sousuo">
<form action="${pageContext.request.contextPath}/selectgoods.do" id="f-sousuo">
<input type="text" name="name" id="goods" placeholder="搜索 你想找的商品">
<input type="submit" value="搜索" id="sousuo">
</form>
</div>
</div> 


<div id="top">
<div class="inner">
<img src="img/jd618.jpg" id="img">
</div>
<div class="inner">
<img src="img/618jd.jpg" id="img">
</div>
<div class="inner">
<img src="img/jddog.jpg" id="img">
</div>
<div id="ul">
<ul>
<li class="first"></li>
<li class="first"></li>
<li class="first"></li>
</ul>
</div>
</div>

<div class="my">
<c:choose>
 <c:when test="${empty user}">
<div class="yongh">
 <img src="img/tmao.jpg" id="txiang">
 <div id="y-dl">
 <a   href="${pageContext.request.contextPath}/login.do">登录</a>
 <a  href="${pageContext.request.contextPath}/register.do">注册</a>
 </div>
 <img src="img/gwct.png" id="gwct">
 </div>
 </c:when>
 <c:otherwise>
 <div id="touxx">
 <img src="img/${user.avator }" id="txiang">
 <form action="${pageContext.request.contextPath }/my.do" id="u-form">
<input type="text" value="${user.account }" id="account" style="display:none;">
<input type="submit" value="你好" id="t-users">
</form>
 <label id="nick-name">${user.nickname }</label>
 </div>
 <img src="img/gwct.png" id="gwct-g">
 </c:otherwise>
 
</c:choose>
</div>

<div class="l-goods">
<c:forEach items="${goods }" var="goods">
<div id="l-goods">
<img src="${pageContext.request.contextPath }/img/${goods.avator }" id="g-img">
<form  action="${pageContext.request.contextPath }/xiangq.do" class="sp-ym">
<input type="text" id="goods_id" name="goods_id" value="${goods.goods_id }">
<input type="submit" id="tijiao">
</form>
<label id="zz" class="zbc">${goods.description}</label>
<label id="money">￥${goods.sum }</label>
<div id="g-bottom">
<label id="g-number">剩余${goods.number }件</label>
<img alt="" src="img/gwck.png" id="gwc">

  <form action="${pageContext.request.contextPath }/insertgwc.do">
  <input type="text" name="user_id" value="${user.account }" id="gw-none">
  <input type="text" name="goods_id" value="${goods.goods_id }" id="gw-none">
  <input type="text" name="merchant" value="${goods.shop }" id="gw-none">
  <input type="text" name="image" value="${goods.avator }" id="gw-none">
  <input type="text" name="description" value="${goods.description }" id="gw-none">
  <input type="text" name="price" value="${goods.sum }" id="gw-none">
  <input type="text" name="number" value="1" id="gw-none">
   <input type="submit" value="购物车" id="gwcar">
  </form>
</div>
</div>
</c:forEach>
</div>

<div id="f-footer">
我也是有底线的
</div>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.11.3.min.js">
</script>
<script type="text/javascript">
	var str=document.getElementsByClassName("zbc");
	for(var i=0;i<str.length;i++){
		if(str[i].innerHTML.length>=12){
			str[i].innerHTML=str[i].innerHTML.substring(0,12)+"...";
		}else{
			str[i].innerHTMML=str[i].innerHTML;
		}
	}
	
var img = document.getElementsByClassName("inner");
var li = document.getElementsByClassName("first");
var index = 0;

function scrol(){
	for(var i=0;i<img.length;i++){
		     	img[i].style.display = "none";
		     	 li[i].style.backgroundColor =""; 
		     	}
		      img[index].style.display = "block";
		     	li[index].style.backgroundColor = "red";
		      index++;
		      if(index==img.length){
		     index=0;
		      }
}
var timer = setInterval(scrol,2000);
function mOver(index){
	clearInterval(timer);
	for(var i=0;i<img.length;i++){
		img[i].style.zIndex ="1";
		li[i].style.backgroundColor="";
	}
	img[index].style.zIndex ="9";
}
function mOut(index){
	var timer = setInterval(scrol,2000);
}
for(var i=0;i<img.length;i++){
	
	li[i].onmouseover=function(){
		mOver(i);
	}
	li[i].onmouseout=function(){
		mOut(i);
	}
}

function tiaozhuan(){
	var ss=$("#gid").val();
	alert(ss);
}
</script>
</body>
</html>